package org.demo.test.akka;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import com.sun.javafx.scene.control.skin.TableColumnHeader;

import java.util.LinkedList;
import java.util.List;

public class AkkaTestMain {

    public static void main(String[] args){
        ActorSystem actorSystem = ActorSystem.create();
        ActorRef actorRef1 = actorSystem.actorOf(Props.create(SenderActor.class), "sender1");
        ActorRef actorRef2 = actorSystem.actorOf(Props.create(SenderActor.class), "sender2");
        ActorRef actorRef3 = actorSystem.actorOf(Props.create(SenderActor.class), "sender3");

        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                actorRef1.tell("1sdf1", actorRef1);
                actorRef1.tell("1sdf2", actorRef1);
                actorRef1.tell("1sdf3", actorRef1);

            }
        });


        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                actorRef2.tell("2sdf3", actorRef2);
                actorRef2.tell("2sdf2", actorRef2);
                actorRef2.tell("2sdf1", actorRef2);

            }
        });

        Thread thread3 = new Thread(new Runnable() {
            @Override
            public void run() {
                actorRef3.tell("3sdf1", actorRef3);
                actorRef3.tell("3sdf2", actorRef3);
                actorRef3.tell("3sdf3", actorRef3);
            }
        });

        thread1.start();
        thread2.start();
        thread3.start();

        try {
            synchronized (actorSystem) {
                actorSystem.wait();
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
